package md.lanjing.com.module_wallet.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.lxh.baselibray.base.XActivity;
import com.lxh.baselibray.constant.ARouterConfig;
import com.lxh.baselibray.dialog.AlertDialog;
import com.lxh.baselibray.util.SizeUtils;

import butterknife.BindView;
import butterknife.OnClick;
import md.lanjing.com.module_wallet.R;
import md.lanjing.com.module_wallet.R2;


/**
 * 充币
 */
public class ChargeCoinActivity extends XActivity {

    @BindView(R2.id.tv_purse_address)
    TextView tvPurseAddress;
    @BindView(R2.id.iv_pic)
    ImageView ivPic;
    @BindView(R2.id.tv_type_select)
    TextView tvTypeSelect;
    @BindView(R2.id.iv_qr_code)
    ImageView ivQrCode;
    private String type="USDT";

    @Override
    public void initData(Bundle savedInstanceState) {
        tvPurseAddress.setText("0xf2956cb4ee39DB088e3F9d5eE1ea132C17E7C575");
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_charge_coin;
    }


    @OnClick({R2.id.tv_type_select, R2.id.tv_hash})
    public void onViewClicked(View view) {
        int i = view.getId();
        if (i == R.id.tv_type_select) {
            showTypeDialog();

        } else if (i == R.id.tv_hash) {
            Intent intent = new Intent(this, HashCharegActivity.class);
            intent.putExtra(HashCharegActivity.TYPE, type);
            startActivity(intent);

        }
    }

    AlertDialog typeDialog = null;
    private void showTypeDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this)
                .addDefaultAnimation()
                .setCancelable(true)
                .setContentView(R.layout.dialog_type_select)
                .fromBottom(true)
                .setWidthAndHeight(ViewGroup.LayoutParams.MATCH_PARENT, SizeUtils.dp2px(context, 80))
                .setOnClickListener(R.id.tv_one, v -> {
                    type = "USDT";
                    ivPic.setImageResource(R.drawable.icon_usdt);
                    tvTypeSelect.setText(type);
                    ivQrCode.setImageResource(R.drawable.icon_uset_qr_code);
                    typeDialog.dismiss();
                }).setOnClickListener(R.id.tv_two, v -> {
                    type = "CAWD";
                    ivPic.setImageResource(R.drawable.icon_cawd);
                    tvTypeSelect.setText(type);
                    ivQrCode.setImageResource(R.drawable.icon_cawd_qr_code);
                    typeDialog.dismiss();
                });
        typeDialog = builder.create();
        typeDialog.show();
    }


}
